package com.hankol.newretail.adapter.details

import android.app.Activity
import android.graphics.Paint
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager.widget.ViewPager
import cn.iwgang.countdownview.CountdownView
import com.baselibrary.BaseConstant
import com.baselibrary.Constants
import com.baselibrary.MessageBus
import com.baselibrary.bean.TabEntity
import com.baselibrary.extension.checkNotNull
import com.baselibrary.extension.checkValue
import com.baselibrary.extension.setMallPriceTTF
import com.baselibrary.router.ActivityRouter
import com.baselibrary.utils.*
import com.baselibrary.view.AutoScrollRecyclerView
import com.baselibrary.view.MarginDecoration
import com.baselibrary.view.RoundCornerImageView
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.flyco.tablayout.CommonTabLayout
import com.flyco.tablayout.listener.CustomTabEntity
import com.flyco.tablayout.listener.OnTabSelectListener
import com.hankol.newretail.R
import com.hankol.newretail.adapter.GoodsLabelAdapter
import com.hankol.newretail.adapter.StoreGoodsAdapter
import com.hankol.newretail.bean.EvaluationBean
import com.hankol.newretail.bean.GoodListBean
import com.hankol.newretail.bean.goods_details.*
import com.hankol.newretail.utils.RetailPopUtils
import com.hankol.newretail.viewmodel.GoodsDetailViewModel
import com.rex.editor.common.DownloadTask
import com.rex.editor.view.RichEditorNew
import com.tencent.rtmp.TXVodPlayer
import java.util.HashMap


/**
 * @author: 关忆北、
 * @date: 2022/7/29
 * @Des：
 */
class GoodsDetailAdapter(var activity: Activity, var viewModel: GoodsDetailViewModel, var commonVodPlayer: TXVodPlayer, var coverHeight: Float, data: List<GoodsDetailsMultiBean>) : BaseMultiItemQuickAdapter<GoodsDetailsMultiBean, BaseViewHolder>(data) {
    private val mTabEntities = ArrayList<CustomTabEntity>()
    val mediaList = ArrayList<GoodsDetailsBanner>()
    var coverVpAdapter: GoodsCoverVpAdapter? = null
    var mOnCloseCallBack: OnCloseCallBack? = null
    var clickButtonListener: ClickButtonListener? = null
    var scrollNavy: AutoScrollRecyclerView? = null
    val fictitiousPerson: ArrayList<FictitiousPersonBean.FictitiousPerson> = arrayListOf()
    var evaluateCount: Int = 0
    var grassShowCount: Int = 0
    var appraiseCount: Int = 0
    var recommendCount: Int = 0
    var mGoodsName = ""
    private var mGoodsDetail: GoodsDetails? = null
    fun setGoodsDetail(mGoodsDetail: GoodsDetails) {
        this.mGoodsDetail = mGoodsDetail
    }

    fun setmGoodsName(goodName: String) {
        this.mGoodsName = goodName
    }

    fun setOnCloseCallBack(mOnCloseCallBack: OnCloseCallBack) {
        this.mOnCloseCallBack = mOnCloseCallBack
    }

    fun setClickButtonBack(clickButtonListener: ClickButtonListener) {
        this.clickButtonListener = clickButtonListener
    }

    fun setFictitiousPerson(mFictitiousPerson: ArrayList<FictitiousPersonBean.FictitiousPerson>) {
        this.fictitiousPerson.clear()
        this.fictitiousPerson.addAll(mFictitiousPerson)
    }

    fun evaluateCount(evaluateCount: Int) {
        this.evaluateCount = evaluateCount
    }

    fun grassShowCount(grassShowCount: Int) {
        this.grassShowCount = grassShowCount
    }

    fun appraiseCount(appraiseCount: Int) {
        this.appraiseCount = appraiseCount
    }

    fun recommendCount(recommendCount: Int) {
        this.recommendCount = recommendCount
    }

    init {
        addItemType(GoodsDetailsMultiBean.TYPE_1, R.layout.item_goods_details_head)
        addItemType(GoodsDetailsMultiBean.TYPE_2, R.layout.item_goods_details_evaluating)
        addItemType(GoodsDetailsMultiBean.TYPE_3, R.layout.item_goods_details_evaluating)
        addItemType(GoodsDetailsMultiBean.TYPE_4, R.layout.item_goods_details_appraise)
        addItemType(GoodsDetailsMultiBean.TYPE_5, R.layout.item_goods_details_img)
        addItemType(GoodsDetailsMultiBean.TYPE_6, R.layout.item_goods_details_recommed)
    }

    override fun convert(helper: BaseViewHolder, item: GoodsDetailsMultiBean) {
        when (item.itemType) {
            GoodsDetailsMultiBean.TYPE_1 -> {
                val bean = item.getSpecialBean()
                if (bean is GoodsDetails) {
                    helper.setText(R.id.tv_goods_det_sold, "月销 ${NumberUtils.formatBigNumForSale("${bean.virtualPayPersonNum}")}+").setGone(R.id.tv_goods_det_sold, bean.virtualPayPersonNum != 0)
                    mediaList.clear()
                    mTabEntities.clear()
                    viewModel.initAuto(mContext)//初始化虚拟人数波动

                    helper.addOnClickListener(R.id.rv_goods_det_tag)//弹窗服务
                    helper.addOnClickListener(R.id.tv_gift)//赠品优惠
                    helper.addOnClickListener(R.id.ll_goods_det_coin)//酒币规则
                    helper.addOnClickListener(R.id.iv_seckill_logo)//秒杀规则
                    helper.addOnClickListener(R.id.tv_seckill_tip)//店铺全部秒杀
                    helper.addOnClickListener(R.id.ll_goods_det_upgrade)//跳转粉丝中心
                    helper.addOnClickListener(R.id.round_hf)//跳转粉丝中心

                    helper.getView<TextView>(R.id.tv_goods_det_name).paint.isFakeBoldText = true
                    helper.getView<TextView>(R.id.tv_goods_det_upgrade).paint.isFakeBoldText = true

                    val vpGoods = helper.getView<ViewPager>(R.id.vp_goods_det_media)
                    val rlGoodsDetMedia = helper.getView<RelativeLayout>(R.id.rl_goods_det_media)
                    val tabGoodsDet = helper.getView<CommonTabLayout>(R.id.stab_goods_det)
                    scrollNavy = helper.getView<AutoScrollRecyclerView>(R.id.ascroll_goods_det_navy)

                    scrollNavy?.tag = scrollNavy.toString()

                    val retailsAutoScrollAdapter = RetailsAutoScrollAdapter()
                    scrollNavy?.layoutManager = LinearLayoutManager(mContext)
                    scrollNavy?.adapter = retailsAutoScrollAdapter
                    fictitiousPerson.shuffle()
                    retailsAutoScrollAdapter.setNewData(fictitiousPerson)
                    viewModel.stopAuto()
                    scrollNavy?.let {
                        it.isSelected = true
                        viewModel.startAuto(it)
                    }

                    val params: LinearLayout.LayoutParams = rlGoodsDetMedia.layoutParams as LinearLayout.LayoutParams
                    params.width = ScreenUtils.getScreenWidth()
                    params.height = coverHeight.toInt()
                    rlGoodsDetMedia.layoutParams = params

                    if (bean.videos.checkNotNull()) {
                        for (index in bean.videos.indices) {
                            val goodsBanner = GoodsDetailsBanner()
                            goodsBanner.video = bean.videos[index].url
                            goodsBanner.cover = bean.videos[index].cover
                            goodsBanner.coverType = GoodsDetailsBanner.GOODS_BANNER_VIDEO
                            mediaList.add(goodsBanner)
                        }
                        mTabEntities.add(TabEntity("视频", 0, 0))
                    }

                    if (bean.covers.checkNotNull()) {
                        for (index in bean.covers.indices) {
                            val goodsBanner = GoodsDetailsBanner()
                            goodsBanner.video = ""
                            goodsBanner.cover = bean.covers[index]
                            goodsBanner.coverType = GoodsDetailsBanner.GOODS_BANNER_IMG
                            mediaList.add(goodsBanner)
                        }
                        mTabEntities.add(TabEntity("图片", 0, 0))
                    }

                    if (mTabEntities.size <= 1) {
                        tabGoodsDet.visibility = View.GONE
                    } else {
                        tabGoodsDet.visibility = View.VISIBLE
                    }
                    if (mediaList.size <= 1) {
                        helper.setGone(R.id.tv_goods_det_page_number, false)
                    } else {
                        helper.setGone(R.id.tv_goods_det_page_number, true)
                    }
                    helper.setText(R.id.tv_goods_det_page_number, "${1}/${mediaList.size}")

                    tabGoodsDet.setTabData(mTabEntities)

                    coverVpAdapter = GoodsCoverVpAdapter(activity, commonVodPlayer)
                    vpGoods.adapter = coverVpAdapter
                    coverVpAdapter?.setData(mediaList)
                    coverVpAdapter?.setGoodName(mGoodsName)
                    vpGoods.offscreenPageLimit = mediaList.size

                    vpGoods.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
                        override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
                        override fun onPageSelected(position: Int) {
                            helper.setText(R.id.tv_goods_det_page_number, "${position + 1}/${mediaList.size}")
                            if (mTabEntities.size > 1) {
                                if (mediaList[position].coverType == GoodsDetailsBanner.GOODS_BANNER_IMG) {
                                    //更改tab选中状态
                                    coverVpAdapter?.goodsVideoView?.stopPlay()
                                    tabGoodsDet.currentTab = 1
                                } else {
                                    tabGoodsDet.currentTab = 0
                                    coverVpAdapter?.goodsVideoView?.startPlay()
                                }
                            }


                        }

                        override fun onPageScrollStateChanged(state: Int) {}
                    })

                    //能点说明必须有两个tab 视频和图片
                    tabGoodsDet.setOnTabSelectListener(object : OnTabSelectListener {
                        override fun onTabSelect(position: Int) {
                            if (position == 0) {
                                vpGoods.setCurrentItem(0, true)
                            } else {
                                //不是0就说明有两个tab，position!=0那指定是图片的
                                if (bean.videos.isNotEmpty() && bean.covers.isNotEmpty()) {
                                    coverVpAdapter?.goodsVideoView?.stopPlay()
                                    vpGoods.setCurrentItem(bean.videos.size, true)

                                }
                            }
                        }

                        override fun onTabReselect(position: Int) {}

                    })

                    val mRoundHf = helper.getView<RoundCornerImageView>(R.id.round_hf)
                    val rvGoodsDetTag = helper.getView<RecyclerView>(R.id.rv_goods_det_tag)
                    if (bean.horizontalBannerList.isNotEmpty()) {
                        mRoundHf.visibility = View.VISIBLE
                        GlideUtils.loadResizableImage(mContext.applicationContext, bean.horizontalBannerList[0].image, mRoundHf, 28)
                    } else {
                        mRoundHf.visibility = View.GONE
                    }

                    val tabAdapter = GoodsLabelAdapter()
                    rvGoodsDetTag.adapter = tabAdapter
                    tabAdapter.setNewData(bean.mallTagDtoList)
                    if (bean.mallTagDtoList.isEmpty()) {
                        rvGoodsDetTag.visibility = View.GONE
                    }
                    val mGoodsServerDesAdapter = GoodsServerDesAdapter()
                    mGoodsServerDesAdapter.setNewData(bean.mallTagDtoList)
                    tabAdapter.setOnItemClickListener { adapter, view, position ->
                        RetailPopUtils.goodsServerPop(activity, mGoodsServerDesAdapter, "")

                    }

                    if (SpUtils.getInstance().isLogin) {
                        helper.setGone(R.id.ll_goods_det_upgrade, SpUtils.getInstance().loadUserBean.data.isFans != 1)
                    } else {
                        helper.setGone(R.id.ll_goods_det_upgrade, true)
                    }
                    val rlNoMember = helper.getView<RelativeLayout>(R.id.rl_no_member)
                    if (SpUtils.getInstance().isFans) {
                        helper.setGone(R.id.rl_goods_fans, true)
                        helper.setGone(R.id.rl_goods_info_title, false)
                        val params: LinearLayout.LayoutParams = rlNoMember.layoutParams as LinearLayout.LayoutParams
                        params.topMargin = ScreenUtils.dip2px(activity.applicationContext, -10f)
                        rlNoMember.layoutParams = params

                        helper.setText(R.id.tv_goods_det_price, "¥" + AmountUtil.changeF2Y(viewModel.getDefFansPrice(bean).toString()))
                    } else {
                        helper.setGone(R.id.rl_goods_fans, false)
                        helper.setGone(R.id.rl_goods_info_title, true)
                        val params: LinearLayout.LayoutParams = rlNoMember.layoutParams as LinearLayout.LayoutParams
                        params.topMargin = 0
                        rlNoMember.layoutParams = params

                        helper.setText(R.id.tv_goods_det_price, "¥" + AmountUtil.changeF2Y(viewModel.getDefPrice(bean).toString()))
                    }
                    if (bean.giftData != null) {
                        if (bean.giftData.mallProductGiftCommodityVos != null) {
                            helper.setGone(R.id.tv_gift, true)
                            helper.setText(R.id.tv_gift, getGiftNames(bean.giftData.mallProductGiftCommodityVos))
                        } else {
                            helper.setGone(R.id.tv_gift, false)
                        }
                    }
                    if (bean.seckillActProductExtDTO.checkNotNull()) {
                        val dto = bean.seckillActProductExtDTO!!
                        var startTime = dto.stime
                        var endTime = dto.etime
                        helper.setGone(R.id.rl_goods_fans, false)
                        helper.setVisible(R.id.rl_seckill_tip, true)
                        var seckillPrice = if (SpUtils.getInstance().isFans) AmountUtil.changeF2Y(viewModel.getDefSeckillFansPrice(bean).toString()) else AmountUtil.changeF2Y(viewModel.getDefSeckillPrice(bean).toString())
                        var originPrice = if (SpUtils.getInstance().isFans) AmountUtil.changeF2Y(viewModel.getDefFansPrice(bean).toString()) else AmountUtil.changeF2Y(viewModel.getDefPrice(bean).toString())
                        if (System.currentTimeMillis() < startTime) {
                            //是否是粉丝
                            helper.setGone(R.id.rl_goods_fans, SpUtils.getInstance().isFans)
                            helper.setGone(R.id.rl_goods_info_title, !SpUtils.getInstance().isFans)
                            helper.setImageResource(R.id.iv_seckill_label, R.drawable.ic_seckill_pre)
                            helper.setText(R.id.tv_seckill_tip, "${TimeUtil.getMonthDayTime(startTime)} 秒杀价¥${seckillPrice} 详情")
                            val button = helper.getView<TextView>(R.id.tv_detail_subscribe)
                            button.visibility = View.VISIBLE
                            if (dto.subscribeFlg == 1) {
                                button.text = "取消提醒"
                                button.setTextColor(ContextCompat.getColor(mContext, R.color.color_999999))
                                button.background = ContextCompat.getDrawable(mContext, R.drawable.shape_90_999999_solid_20dp)
                                button.setOnClickListener { clickButtonListener?.onClickButton(1, 0, dto.seckillActId) }
                            } else {
                                button.text = "预约提醒"
                                button.setTextColor(ContextCompat.getColor(mContext, R.color.white))
                                button.background = ContextCompat.getDrawable(mContext, R.drawable.shape_f54d53_solid_20dp)
                                button.setOnClickListener { clickButtonListener?.onClickButton(2, 0, dto.seckillActId) }
                            }
                        } else if (System.currentTimeMillis() in startTime..endTime) {
                            helper.setGone(R.id.rl_seckill, true)
                            GlideUtils.loadImg(mContext, dto.secKillIcon, helper.getView(R.id.iv_seckill_logo))
                            helper.getView<ImageView>(R.id.iv_seckill_logo).setOnClickListener {
                                RetailPopUtils.goodsServerPop(activity, null, dto.ruleContent, "秒杀规则")
                            }
                            helper.setGone(R.id.rl_goods_info_title, false)
                            helper.setGone(R.id.tv_goods_det_retail, false)
                            val params: LinearLayout.LayoutParams = rlNoMember.layoutParams as LinearLayout.LayoutParams
                            params.topMargin = ScreenUtils.dip2px(activity.applicationContext, -10f)
                            rlNoMember.layoutParams = params
                            helper.setText(R.id.tv_goods_seckill_price, seckillPrice)
                            helper.setText(R.id.tv_seckill_origin_price, if (SpUtils.getInstance().isFans) "粉丝价 ¥$originPrice" else "零售价 ¥$originPrice")
                            helper.getView<TextView>(R.id.tv_seckill_origin_price).paint.flags = Paint.STRIKE_THRU_TEXT_FLAG
                            var timer = helper.getView<CountdownView>(R.id.tv_seckill_left_time)
                            timer.start(endTime - System.currentTimeMillis())
                            timer.setOnCountdownEndListener {
                                //秒杀活动结束 要重置
                                bean.seckillActProductExtDTO = null
                                notifyItemChanged(helper.adapterPosition)
                            }
                        } else {
                            helper.setGone(R.id.rl_goods_info_title, true)
                        }

                    } else {
                        helper.setGone(R.id.rl_seckill_tip, false)
                    }
                    if (bean.giftData != null) {
                        if (bean.giftData.mallProductGiftCommodityVos != null) {
                            helper.setGone(R.id.tv_gift, true)
                            helper.setText(R.id.tv_gift, getGiftNames(bean.giftData.mallProductGiftCommodityVos))
                        } else {
                            helper.setGone(R.id.tv_gift, false)
                        }
                    }
                    helper.setText(R.id.tv_goods_det_name, bean.name).setText(R.id.tv_goods_det_title, bean.subTitle).setGone(R.id.tv_goods_det_title, bean.subTitle.checkNotNull()).setText(R.id.tv_goods_det_sold, if (bean.virtualPayPersonNum > 0) "月销 ${NumberUtils.formatBigNumForSale(bean.virtualPayPersonNum.toString())}+" else "").setText(R.id.tv_goods_monthly_sales, if (bean.virtualPayPersonNum > 0) "月销 ${NumberUtils.formatBigNumForSale(bean.virtualPayPersonNum.toString())}+" else "").setText(R.id.tv_goods_fans_price, AmountUtil.changeF2Y(viewModel.getDefFansPrice(bean).toString())).setText(R.id.tv_goods_retail_price, "零售价 ¥" + AmountUtil.changeF2Y(viewModel.getDefPrice(bean).toString())).setText(R.id.tv_goods_det_price, AmountUtil.changeF2Y(viewModel.getDefPrice(bean).toString())).setGone(R.id.ll_goods_det_coin, bean.scorePayPower == 1)
                    helper.getView<TextView>(R.id.tv_goods_fans_price).setMallPriceTTF(mContext)
                    helper.getView<TextView>(R.id.tv_unit_fans).setMallPriceTTF(mContext)
                    helper.getView<TextView>(R.id.tv_goods_det_price).setMallPriceTTF(mContext)
                    helper.getView<TextView>(R.id.tv_unit).setMallPriceTTF(mContext)
                    if (bean.shopInfo.checkNotNull() && bean.shopInfo.shopId != 0) {
                        helper.setGone(R.id.rl_cellar_info, true)
                        GlideUtils.loadImg_228(mContext, bean.shopInfo.image, helper.getView(R.id.rcv_cellar))
                        helper.setText(R.id.tv_cellar_name, bean.shopInfo.name)
                        helper.setText(R.id.tv_cellar_address, bean.shopInfo.detailAddress.checkValue())
                        val tvCellarDistance = helper.getView<TextView>(R.id.tv_cellar_distance)
                        if (SpUtils.getFloat(ContextUtils.getCurApplication(), "address_Lat", 0f) != 0f) {
                            val userLag = SpUtils.getFloat(ContextUtils.getCurApplication(), "address_long", 0f).toDouble()
                            val userLat = SpUtils.getFloat(ContextUtils.getCurApplication(), "address_Lat", 0f).toDouble()
                            if (bean.shopInfo.longitude.checkNotNull() && bean.shopInfo.latitude.checkNotNull()) {
                                tvCellarDistance.text = DistanceUtils.getDistance(bean.shopInfo.longitude.toDouble(), bean.shopInfo.latitude.toDouble(), userLag, userLat)
                            } else {
                                tvCellarDistance.text = "0.0km"
                            }
                            val drawable = ContextCompat.getDrawable(mContext, R.drawable.ic_distance_arrow)
                            tvCellarDistance.compoundDrawablePadding = ScreenUtils.dpToPx(5)
                            tvCellarDistance.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null)
                            helper.getView<RelativeLayout>(R.id.rl_cellar_info).setOnClickListener {
                                val hashMap = HashMap<String, Any>()
                                hashMap["id"] = bean.shopInfo.wineryId
                                hashMap["dealerCode"] = bean.shopInfo.dealerCode
                                ARouterUtils.jump(ActivityRouter.WINE_CELLAR.WINCE_CELLAR_DETAIL, hashMap)
                            }
                            tvCellarDistance.setTextColor(ContextCompat.getColor(mContext, R.color.color_999999))
                        } else {
                            tvCellarDistance.text = "开启定位"
                            tvCellarDistance.setTextColor(ContextCompat.getColor(mContext, R.color.color_F54D53))
                            tvCellarDistance.setOnClickListener {
                                if (CommonUtil.isLocationEnabled(mContext)) {
                                    EventBusUtils.sendNotify(MessageBus.msgId_location_permission_apply)
                                } else {
                                    CommonUtil.openGpsSettings()
                                }
                            }
                        }
                    } else {
                        helper.setGone(R.id.rl_cellar_info, false)
                    }

                }
            }
            GoodsDetailsMultiBean.TYPE_2 -> {
                val bean = item.getSpecialBean()
                helper.setText(R.id.tv_goods_evaluating_des, "达人评测（${evaluateCount}）").setGone(R.id.ll_goods_evaluating_more, false)
                val goodsEvaluatingAdapter = GoodsEvaluatingAdapter()
                helper.getView<RecyclerView>(R.id.rv_goods_evaluating_list).adapter = goodsEvaluatingAdapter
                goodsEvaluatingAdapter.setNewData(bean as List<DaManReviewBean>)
                goodsEvaluatingAdapter.setGoodsDetail(mGoodsDetail!!)
                goodsEvaluatingAdapter.setOnItemClickListener(object : GoodsEvaluatingAdapter.OnItemClickListener {
                    override fun itemClickListener() {
                        mOnCloseCallBack?.onCloseCall()
                    }

                })
            }
            GoodsDetailsMultiBean.TYPE_3 -> {
                val bean = item.getSpecialBean()
                val grassShowBean = bean as List<GrassShowBean>
                helper.addOnClickListener(R.id.ll_goods_evaluating_more)//种草
                helper.setText(R.id.tv_goods_evaluating_des, "种草秀（${grassShowCount}）").setGone(R.id.ll_goods_evaluating_more, true)
                val goodsEvaluatingAdapter = GoodsPlantAdapter()
                helper.getView<RecyclerView>(R.id.rv_goods_evaluating_list).adapter = goodsEvaluatingAdapter
                goodsEvaluatingAdapter.setNewData(grassShowBean)
                goodsEvaluatingAdapter.setGoodsDetail(mGoodsDetail!!)
                goodsEvaluatingAdapter.setOnItemClickListener(object : GoodsPlantAdapter.OnItemClickListener {
                    override fun itemClickListener() {
                        mOnCloseCallBack?.onCloseCall()
                    }

                })
            }
            GoodsDetailsMultiBean.TYPE_4 -> {
                val bean = item.getSpecialBean()
                val appraiseShowBean = bean as List<EvaluationBean>
                helper.addOnClickListener(R.id.ll_goods_all_appraise)//查看全部评价
                helper.addOnClickListener(R.id.tv_see_all_appraise)//查看全部评价
                helper.setText(R.id.tv_goods_evaluating_des, "评价（${appraiseCount}）")
                helper.setText(R.id.tv_see_all_appraise, "查看全部评价（${appraiseCount}）")
                val goodsEvaluatingAdapter = GoodsAppraiseAdapter()
                helper.getView<RecyclerView>(R.id.rv_goods_evaluating_list).adapter = goodsEvaluatingAdapter
                helper.setGone(R.id.tv_see_all_appraise, appraiseShowBean.size > 2)
                val tempBean = mutableListOf<EvaluationBean>()
                if (appraiseShowBean.size == 1) {
                    tempBean.add(appraiseShowBean[0])
                } else if (appraiseShowBean.size >= 2) {
                    tempBean.add(appraiseShowBean[0])
                    tempBean.add(appraiseShowBean[1])
                }
                goodsEvaluatingAdapter.setGoodsDetail(mGoodsDetail!!)
                goodsEvaluatingAdapter.setNewData(tempBean)
                goodsEvaluatingAdapter.onItemChildClickListener = OnItemChildClickListener { _, view, position ->
                    when (view.id) {
                        R.id.civ_avatar, R.id.tv_name -> goUserHomePage(goodsEvaluatingAdapter.data[position].user.id)
                        R.id.civ_shop_avatar, R.id.tv_shop_name -> goUserHomePage(goodsEvaluatingAdapter.data[position].ownerReplyList[0].user.id)
                    }
                }
            }
            GoodsDetailsMultiBean.TYPE_5 -> {
                val bean = item.getSpecialBean()
                if (bean is GoodsDetails) {
                    val bridgeWeb = helper.getView<RichEditorNew>(R.id.bridge_goods_details_web)
                    if (!TextUtils.isEmpty(bean.desc)) {
                        bridgeWeb.loadRichEditorCode(bean.desc)
                        bridgeWeb.setOnClickImageTagListener { url: String? ->
                            mOnCloseCallBack?.onCloseCall()
                            //点击事件
                            val bundle = Bundle()
                            bundle.putStringArrayList(Constants.WIKI_PICTURE_LIST, arrayListOf(url))
                            bundle.putInt(Constants.WIKI_PICTURE_INDEX, helper.adapterPosition)
                            ActivityRouter.startActivity(ActivityRouter.ACTIVITY.BROWSE_MEDIA, bundle)
                        }
                        bridgeWeb.setDownloadListener(DownloadTask.getDefaultDownloadListener(activity.applicationContext))
                    }

                }
            }
            GoodsDetailsMultiBean.TYPE_6 -> {

                val bean = item.getSpecialBean()
                val rvRecommendList = helper.getView<RecyclerView>(R.id.rv_goods_recommend_list)
                val recommendAdapter = StoreGoodsAdapter()

                rvRecommendList.layoutManager = GridLayoutManager(mContext, 2)
                rvRecommendList.adapter = recommendAdapter
                if (rvRecommendList.itemDecorationCount == 0) {
                    rvRecommendList.addItemDecoration(MarginDecoration(mContext, 9))
                }
                helper.setText(R.id.tv_goods_recommend_des, "精选（${recommendCount}）")
                recommendAdapter.setNewData(bean as List<GoodListBean>)
                recommendAdapter.setOnItemClickListener { adapter, view, position ->
                    if (!DoubleUtils.isFastDoubleClick()) {
                        val bean = adapter.data[position] as GoodListBean
                        //进入对应详情页面
                        val map = java.util.HashMap<String, Any>()
                        map[Constants.GOODS_DETAIL_ID] = bean.id
                        ARouterUtils.jump(ActivityRouter.NEW_RETAIL.GOODS_DETAUILS, map)
                        mOnCloseCallBack?.onCloseCall()
                    }
                }
            }
        }
    }

    private fun getGiftNames(mallProductGiftCommodityVos: ArrayList<MallProductGiftCommodityVo>): String {
        val sb = StringBuilder()
        for (data in mallProductGiftCommodityVos) {
            val sb2 = StringBuilder()
            for (spec in data.specList) {
                sb2.append(spec.value)
            }
            sb.append(data.spuName + sb2)
            if (mallProductGiftCommodityVos.size > 1) {
                sb.append("、")
            }
        }
        return sb.toString()
    }

    private fun goUserHomePage(userId: Int) {
        val hashMap = HashMap<String, Any>()
        hashMap[BaseConstant.USER_ID] = userId
        ARouterUtils.jump(ActivityRouter.MINE_CENTER.USER_INFO, hashMap)
    }

    interface ClickButtonListener {
        fun onClickButton(status: Int, postition: Int, actId: Int)
    }

    interface OnCloseCallBack {
        fun onCloseCall()
    }

}